import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StaffVO, StaffForm, StaffQuery } from '@/api/finance/staff/types';

/**
 * 查询员工列表
 * @param query
 * @returns {*}
 */

export const listStaff = (query?: StaffQuery): AxiosPromise<StaffVO[]> => {
  return request({
    url: '/finance/staff/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询员工详细
 * @param id
 */
export const getStaff = (id: string | number): AxiosPromise<StaffVO> => {
  return request({
    url: '/finance/staff/' + id,
    method: 'get'
  });
};

/**
 * 新增员工
 * @param data
 */
export const addStaff = (data: StaffForm) => {
  return request({
    url: '/finance/staff',
    method: 'post',
    data: data
  });
};

/**
 * 修改员工
 * @param data
 */
export const updateStaff = (data: StaffForm) => {
  return request({
    url: '/finance/staff',
    method: 'put',
    data: data
  });
};

/**
 * 删除员工
 * @param id
 */
export const delStaff = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/staff/' + id,
    method: 'delete'
  });
};
